<?php
namespace Lyricist\Controller;
use Common\Controller\LyricistController;
class TestController extends LyricistController {


    public function index(){

        $url = "https://lyrics.apksc.com/v2.3/api/Activity/getAllQuestion.html";

        $data = array(
            'phpsessid'=>'n2n5r4vahi8ubjr26ncil3c2o6',
            'aid'=>'4698295',
        );
        for ($i=0;$i<1000;$i++){
            $res = $this->getcomponent($url,$data);

            $arr[] = $res;
            if ($i%50==0){
                sleep(1);
            }
        }

        S('lyricistquestion',$arr,3600*24*7);

        exit('ok');

    }

    public function rank(){

        $rank = $this->cachecash();

        var_dump($rank);

    }

    public function test(){

        $data = S('lyricistquestion');

        $arr = array();
        foreach ($data as $key=>$val){

            //print_r($val['Result']['Questions']);

            foreach ($val['Result']['Questions'] as $value){

                var_dump($value);
                $arr[$value['Id']] = $value;

            }

        }
       echo count($arr);
        S('caici',$arr);
       // print_r($arr);


    }

    public function test1(){

        exit;
      $data = S('caici');

      foreach ($data as $val){

          $insert = array(
              'Number'=>$val['Number'],
              'Title'=>json_encode($val['Title']),
              'Answer'=>json_encode($val['Answer']),
              'TimeLong'=>$val['TimeLong'],
              'Index'=>$val['Index']
          );
            M('lyricist_question')->data($insert)->add();
      }

      echo 'ok';

    }


}